package com.google.code.mochaccino.framework.jaxws;
/*
 * Copyright 2012 Claude Houle claude.houle@gmail.com
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

import javax.jws.WebService;

/** Utility Class to create a web-service definition in a declarative way (no-xml). */
public final class WSEndpointDefinition {

	private String     path;
	private WebService webService;
	private Object     wsImpl;

	public WSEndpointDefinition() {
	}

	public WSEndpointDefinition( String path, Object wsImpl ) {
		this.wsImpl = wsImpl;
		if ( this.wsImpl == null ) {
			throw new IllegalArgumentException( "WebService implementation is null" );
		}

		this.path = path;
		if ( this.path == null ) {
			throw new IllegalArgumentException( "WebService path is null" );
		}

		this.webService = this.wsImpl.getClass().getAnnotation( WebService.class );
		if ( webService == null ) {
			throw new IllegalArgumentException( String.format( "WebService at path %s does not possess annotation %s", path, WebService.class.getName() ) );
		}
	}

	public String getPath() {
		return path;
	}

	public WebService getWebService() {
		return webService;
	}

	public Object getWsImpl() {
		return wsImpl;
	}


}
